using System;
using System.Xml;

using System.Collections;
using System.Collections.Specialized;

namespace CSharpDistilled.Diagnostics
{
    /// <summary>
    /// Represents a provider defined within a configuration file.
    /// </summary>
    internal sealed class Provider
    {
        #region Provider Private Fields

        private string m_name;
        private string m_type;

        NameValueCollection m_attributes;

        #endregion

        #region internal Provider(XmlAttributeCollection attributes)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:CSharpDistilled.Diagnostics.Provider"/> class.
        /// </summary>
        /// <param name="attributes">The Xml attributes associated with the <see cref="T:CSharpDistilled.Diagnostics.Provider"/> within the configuration file.</param>
        internal Provider(XmlAttributeCollection attributes)
        {
            m_attributes = new NameValueCollection();

            // set the name of the provider
            m_name = attributes["name"].Value;

            // set the type of the provider
            m_type = attributes["type"].Value;

            foreach (XmlAttribute attribute in attributes)
            {
                if (attribute.Name != "name" && attribute.Name != "type")
                {
                    m_attributes.Add(attribute.Name, attribute.Value);
                }
            }
        }

        #endregion

        #region internal string Name

        /// <summary>
        /// Gets the name of the provider specified within the configuration section.
        /// </summary>
        internal string Name
        {
            get
            {
                return m_name;
            }
        }

        #endregion

        #region internal string Type

        /// <summary>
        /// Gets the type of the provider specified within the configuration section.
        /// </summary>
        internal string Type
        {
            get
            {
                return m_type;
            }
        }

        #endregion
    }
}